<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      v-model="form"
      :data="data"
      :page.sync="page"
      :search.sync="query"
      :permission="permissionList"
      :before-open="beforeOpen"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @row-del="rowDel"
      @selection-change="selectionChange"
      @search-change="searchChange"
      @search-reset="searchReset"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button type="success" size="small" icon="el-icon-download" v-if="permission.cqcInspectionRecords_export" @click="handleExport">导出</el-button>
        <el-button type="warning" size="small" icon="el-icon-check" v-if="permission.cqcInspectionRecords_revoke" @click="handleSecondTimeInspection">二次检</el-button>
      </template>
      <template slot-scope="{ row }" slot="menu">
        <el-button type="text" size="small" icon="el-icon-view" @click="handleEdit(row, 'view')">详情</el-button>
        <el-button type="text" size="small" icon="el-icon-edit" @click="handleEdit(row, 'edit')">编辑</el-button>
        <el-button size="small" type="text" v-if="permission.cqcInspectionRecords_reportForms" @click="viewQcExamineReport(row)">检验报表</el-button>
        <el-button size="small" type="text" v-if="permission.cqcInspectionRecords_report" @click="viewApaasExamineReport(row)">检验报告</el-button>
      </template>
      <template slot="menuRight">
        <user-table-config :option="option" @confirm="(val) => handleSetUserConfig(val, pageCode)"></user-table-config>
      </template>
    </avue-crud>
    <el-dialog append-to-body :close-on-click-modal="false" title="撤销检验" :visible.sync="revokeDialog" :before-close="revokeDialogClose">
      <avue-form ref="revokeForm" v-if="revokeDialog" v-model="revokeForm" :option="revokeOption"></avue-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click="revokeSubmit"><i class="el-icon-circle-plus-outline"></i><span>提 交</span></el-button>
        <el-button size="small" @click="addAbnormalDialog = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
    <!--公用模态弹框-->
    <common-modal-template ref="commonModalTemplate" :option="tableOption" @getSelectedRows="getSelectedRows"> </common-modal-template>
    <export-comp
      ref="exportComp"
      page-api-url="mes-product/qms-inspection-document/page?statusStr=2,3,5,6&documentType=CQC"
      :option="option"
      :page="page"
      :query="exportParams"
      file-name="完工检验记录"
    ></export-comp>
    <viewAndEditInspect
      ref="handleInspect"
      v-if="openHandleDialogType"
      :visible.sync="handleVisable"
      :openDialogType="openDialogType"
      :paramValue="paramValue"
      @closeDialog="handleCloseBeforeInspect"
    ></viewAndEditInspect>
    <!--检验报告-->
    <el-dialog
      v-if="apaasInspectionReportDialog"
      fullscreen
      append-to-body
      :modal-append-to-body="true"
      :close-on-click-modal="false"
      title="检验报告"
      :visible.sync="apaasInspectionReportDialog"
    >
      <view-apaas-inspection-report :operateBtn="false" v-if="apaasInspectionReportDialog" ref="apaasReport"></view-apaas-inspection-report>
    </el-dialog>
  </basic-container>
</template>
<script>
import { mapGetters } from 'vuex';
import userTableConfig from '@/components/user-table-config/index.vue';
import userConfig from '@/mixins/userConfig';
import exportComp from '@/components/export-comp';
import commonModalTemplate from '@/components/common-modal-template/common-modal-template';
import { filterEmptyValues } from '@/util/util';
import { getList, add, getWorkOrderDetail, getLineList, getDetail, getSubTypeList, revoke, handle, secondTimeInspection } from '@/api/quality/completeInspectRecords';
import website from '@/config/website';
import { Base64 } from 'js-base64';
import { getToken } from '@/util/auth';
import exportExcel from '@/components/export-excel';
import viewAndEditInspect from './components/addAndEditCompleteInspect';
import moment from 'moment';
import viewApaasInspectionReport from '@/views/designer/preview';
export default {
  name: 'completeInspectRecords',
  components: {
    userTableConfig,
    commonModalTemplate,
    exportExcel,
    exportComp,
    viewAndEditInspect,
    viewApaasInspectionReport
  },
  mixins: [userConfig()],
  created() {
    let queryParams = this.$route.query;
    if (queryParams && queryParams.partNo) {
      this.query.partNo = decodeURIComponent(queryParams.partNo);
    }
    if (queryParams && queryParams.date) {
      const date = queryParams.date;
      const curDate = `${date}-01 00:00:00`;
      let examineStartTime = this.$moment(date).format('YYYY-MM-DD HH:mm:ss');
      let daysInMonth = this.$moment(date, 'YYYY-MM').daysInMonth();
      let examineEndTime = this.$moment(examineStartTime)
        .add(daysInMonth - 1, 'days')
        .format('YYYY-MM-DD 23:59:59');
      this.$set(this.query, 'examineDate', [examineStartTime, examineEndTime]);
    }
    if (queryParams && queryParams.lineName) {
      const lineName = decodeURIComponent(queryParams.lineName);
      this.$set(this.query, 'lineName', lineName);
    }
  },
  data() {
    return {
      form: {},
      query: {},
      tableOption: {},
      modalName: '',
      loading: false,
      handleVisable: false,
      apaasInspectionReportDialog: false,
      paramValue: false,
      openDialogType: '',
      page: {
        pageSize: 20,
        currentPage: 1,
        total: 0
      },
      exportParams: {},
      data: [],
      option: {
        height: 'calc(100vh - 408px)',
        searchMenuSpan: 24,
        searchMenuPosition: 'right',
        calcHeight: 30,
        selectionList: [],
        tip: false,
        searchShow: true,
        border: true,
        index: true,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        indexLabel: '序号',
        columnBtn: false,
        selection: true,
        menuWidth: 260,
        column: [
          {
            label: '检验单号',
            prop: 'documentNo',
            searchOrder: 5,
            type: 'search',
            search: true,
            appendClick: () => {
              this.openCommon('documentNo');
            }
          },
          {
            label: '工单号',
            prop: 'sourceNo',
            type: 'search',
            search: true,
            searchOrder: 4,
            appendClick: () => {
              this.openCommon('sourceNo');
            }
          },
          {
            label: '客户名称',
            prop: 'partnerName',
            search: true,
            searchOrder: 2,
            type: 'search',
            appendClick: () => {
              this.openCommon('partnerName');
            }
          },
          {
            label: '产品编码',
            prop: 'partNo',
            type: 'search',
            search: true,
            searchOrder: 1,
            appendClick: () => {
              this.openCommon('partNo');
            }
          },
          {
            label: '产品名称',
            prop: 'partName'
          },
          {
            label: '产品型号',
            prop: 'partModel'
          },
          {
            label: '产线',
            prop: 'lineName',
            search: true,
            type: 'select',
            searchOrder: 7,
            dicUrl: '/api/mes-product/productionline/list',
            props: {
              label: 'name',
              value: 'name'
            }
          },
          {
            label: '工单计划数量',
            prop: 'workOrderQuantity'
          },
          {
            label: '工单完工数量',
            prop: 'workOrderCompletedQuantity'
          },
          { label: '报检数量', prop: 'sendExamineQuantity' },
          { label: '检验数量', prop: 'examineQuantity' },
          { label: '检验结果', prop: 'examineResult' },
          { label: '合格数量', prop: 'okQuantity' },
          { label: '不合格数量', prop: 'ngQuantity' },
          {
            label: '不合格率',
            prop: 'ngRate'
          },
          {
            label: '是否加急',
            prop: 'isUrgent',
            search: true,
            searchOrder: 3,
            type: 'select',
            dicData: [
              { label: '是', value: true },
              { label: '否', value: false }
            ]
          },
          {
            label: '检验状态',
            prop: 'status',
            type: 'select',
            dicData: [
              { label: '未检验', value: 1 },
              { label: '已检验', value: 2 },
              { label: '待入库', value: 3 },
              { label: '草稿', value: 4 },
              { label: '超期关闭', value: 5 },
              { label: '已撤销', value: 6 }
            ]
          },
          {
            label: '检验方式',
            prop: 'examineMode',
            order: 8,
            type: 'select',
            dicUrl: '/api/blade-system/dict/dictionary?code=inspection_mode',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            }
          },
          {
            label: '报检时间',
            prop: 'createTime',
            width: 130
          },
          {
            label: '检验时间',
            prop: 'updateTime',
            width: 130
          },
          {
            label: '检验人',
            prop: 'examineByName'
          },
          {
            label: '不良处理人',
            prop: 'disposeByName'
          },
          {
            label: '检验时间',
            prop: 'examineDate',
            searchType: 'datetimerange',
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '开始日期',
            endPlaceholder: '结束日期',
            search: true,
            hide: true,
            searchOrder: 6
          }
        ]
      },
      lineList: [],
      documentNo: '',
      attachmentsList: [],
      inspectionPictureList: [],
      pictureList: [],
      abnormalRecordIndex: 0,
      mainTypeList: [],
      subTypeList: [],
      openHandleDialogType: 'edit',
      exprotVisible: false,
      btnLoading: false,
      exportData: []
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.$structuralSplit();
    });
  },
  computed: {
    ...mapGetters(['permission']),
    permissionList() {
      return {
        delBtn: this.vaildData(this.permission.plan_config_del, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(',');
    },
    headersObj() {
      let header = { Authorization: `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` };
      header['Blade-Auth'] = 'bearer ' + getToken();
      return header;
    },
    isView() {
      return this.openHandleDialogType == 'view';
    }
  },
  methods: {
    async viewQcExamineReport(row) {
      window.open(`${this.website.reportUrl}/preview?_u=blade-完工检验报表模板.ureport.xml&qcId=${row.id}`);
    },
    viewApaasExamineReport(row) {
      if (!row.examineContent) {
        this.$message({
          type: 'warning',
          message: '检验报告信息不存在!'
        });
        return;
      }
      let examineContent = JSON.parse(row.examineContent || '{}');
      this.apaasInspectionReportDialog = true;
      this.$nextTick(() => {
        this.$refs.apaasReport.setDataJson(examineContent);
      });
    },
    handleCloseBeforeInspect() {
      this.onLoad(this.page);
    },
    rowSave(row, done, loading) {},
    rowUpdate(row, index, done, loading) {},
    rowDel(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // ajax
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
        });
    },
    handleAdd() {
      this.addDialog = true;
    },
    handleEdit(row, type) {
      this.openDialogType = type;
      this.handleVisable = true;
      this.$refs.handleInspect.getData(row.id);
    },
    handleClose(done) {
      this.$refs.inspectionResultsRecordForm.resetFields();
      this.inspectionResultsRecordForm = {};
      done();
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.revokeDialog = true;
      this.revokeForm = this.selectionList[0];
    },
    revokeSubmit() {
      this.$refs.revokeForm.validate((valid, done) => {
        if (valid) {
          const data = { id: this.revokeForm.id, revocation: this.revokeForm.revocation };
          revoke(data).then((res) => {
            this.$message.success(res.data.msg);
            this.revokeDialog = false;
            this.onLoad(this.page);
          });
        }
      });
    },
    beforeOpen(done, type) {},
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    onLoad(page, params = {}) {
      this.loading = true;
      params.descs = 'update_time';
      console.log(this.query);
      if (this.query.examineDate && this.query.examineDate.length > 0) {
        params.examineStartTime = this.query.examineDate[0];
        params.examineEndTime = this.query.examineDate[1];
      }
      console.log(params);
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query, { documentType: 'CQC' })).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        data.records.forEach((item) => {
          item.okQuantity = item.examineQuantity - item.ngQuantity;
        });
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    openWorkOrderCommonModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'workOrderModal';
      this.tableOption = {
        modalTitle: '选择工单号（双击进行选择）',
        url: '/api/mes-product/work-order/page?workOrderStatus=2,3',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '生产订单',
            prop: 'productionOrderNo',
            search: true
          },
          {
            label: '生产工单',
            prop: 'orderNo',
            search: true
          },
          {
            label: '工单类型',
            prop: 'orderType',
            type: 'select',
            dicUrl: '/api/blade-system/dict/dictionary?code=order_type',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            }
          },
          {
            label: '工单数量',
            prop: 'planQuantity'
          },
          {
            label: '产品编码',
            prop: 'partNo',
            search: true
          },
          {
            label: '产品名称',
            prop: 'partName'
          },
          {
            label: 'BOM版本',
            prop: 'bomVersion'
          },
          {
            label: '派工产线',
            prop: 'productionLineName'
          },
          {
            label: '计划开始时间',
            prop: 'planStartDate'
          },
          {
            label: '计划结束时间',
            prop: 'planEndDate'
          },
          {
            label: '制定人',
            prop: 'creatorName'
          },
          {
            label: '状态',
            prop: 'status',
            type: 'select',
            dicData: [
              {
                label: '待排程',
                value: 1
              },
              {
                label: '待生产',
                value: 2
              },
              {
                label: '生产中',
                value: 3
              },
              {
                label: '完工',
                value: 4
              },
              {
                label: '锁定',
                value: 5
              },
              {
                label: '强制完工',
                value: 6
              }
            ]
          },
          {
            label: '备注',
            prop: 'remark'
          }
        ]
      };
    },
    openFailureCommonModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'failureModal';
      this.tableOption = {
        modalTitle: '不良现象（双击进行选择）',
        url: '/api/mes-product/mro-dict/page?dictType=BAD_PHENOMENON',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '不良代码',
            prop: 'code',
            search: true
          },
          {
            label: '不良现象描述',
            prop: 'name'
          }
        ]
      };
    },

    getWorkOrderDetail(workOrderNo) {
      getWorkOrderDetail(workOrderNo, 'FAI').then((res) => {
        this.addForm.workshopId = this._get(res, 'data.data.workOrderVO.workshopId', '');
        this.addForm.workshopName = this._get(res, 'data.data.workOrderVO.workshopName', '');
        this.addForm.lotNo = this._get(res, 'data.data.workOrderVO.lotNo', '');
        this.documentNo = this._get(res, 'data.data.documentNo', '');
      });
    },
    handleExport() {
      const params = this._cloneDeep(this.query);
      if (params.examineDate && params.examineDate.length > 0) {
        params.examineStartTime = this.query.examineDate[0];
        params.examineEndTime = this.query.examineDate[1];
        delete params.examineDate;
      }
      this.exportParams = Object.assign(filterEmptyValues(params), { statusStr: '2,3,5,6', documentType: 'CQC' });
      this.$refs.exportComp.visible = true;
    },
    openUserCommonModal() {
      this.modalName = 'userModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择检验人员信息（双击进行选择）',
        url: '/api/blade-system/user/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '用户姓名',
            prop: 'realName',
            search: true,
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '所属部门',
            prop: 'deptName',
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '职务',
            prop: 'postName'
          },
          {
            label: '用户平台',
            prop: 'userTypeName'
          }
        ]
      };
    },
    handleSecondTimeInspection() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('二次检，会自动生成一张关联的完工待检单，是否继续？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          return secondTimeInspection(this.selectionList[0].id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
        });
    },
    openCommon(type) {
      if (type == 'partNo') {
        this.modalName = 'partNoModal';
        this.$refs.commonModalTemplate.showModal();
        this.tableOption = {
          modalTitle: '物料数据（双击进行选择）',
          url: '/api/mes-admin/part-master/page?semifinished=true',
          isPage: true,
          rowSelectionType: 'single',
          columnDefs: [
            {
              label: '物料编码',
              prop: 'partNo',
              search: true
            },
            {
              label: '物料名称',
              prop: 'name',
              search: true
            },
            {
              label: '产品型号',
              prop: 'partModel'
            }
          ]
        };
      } else if (type == 'sourceNo') {
        this.$refs.commonModalTemplate.showModal();
        this.modalName = 'sourceNoModal';
        this.tableOption = {
          modalTitle: '选择工单号（双击进行选择）',
          url: '/api/mes-product/work-order/page?workOrderStatus=2,3',
          isPage: true,
          rowSelectionType: 'single',
          columnDefs: [
            {
              label: '生产订单',
              prop: 'productionOrderNo',
              search: true
            },
            {
              label: '生产工单',
              prop: 'orderNo',
              search: true
            },
            {
              label: '工单类型',
              prop: 'orderType',
              type: 'select',
              dicUrl: '/api/blade-system/dict/dictionary?code=order_type',
              props: {
                label: 'dictValue',
                value: 'dictKey'
              }
            },
            {
              label: '工单数量',
              prop: 'planQuantity'
            },
            {
              label: '产品编码',
              prop: 'partNo',
              search: true
            },
            {
              label: '产品名称',
              prop: 'partName'
            },
            {
              label: 'BOM版本',
              prop: 'bomVersion'
            },
            {
              label: '派工产线',
              prop: 'productionLineName'
            },
            {
              label: '计划开始时间',
              prop: 'planStartDate'
            },
            {
              label: '计划结束时间',
              prop: 'planEndDate'
            },
            {
              label: '制定人',
              prop: 'creatorName'
            },
            {
              label: '状态',
              prop: 'status',
              type: 'select',
              dicData: [
                {
                  label: '待排程',
                  value: 1
                },
                {
                  label: '待生产',
                  value: 2
                },
                {
                  label: '生产中',
                  value: 3
                },
                {
                  label: '完工',
                  value: 4
                },
                {
                  label: '锁定',
                  value: 5
                },
                {
                  label: '强制完工',
                  value: 6
                }
              ]
            },
            {
              label: '备注',
              prop: 'remark'
            }
          ]
        };
      } else if (type == 'documentNo') {
        this.modalName = 'documentNoModel';
        this.$refs.commonModalTemplate.showModal();
        this.tableOption = {
          modalTitle: '选择检验单号（双击进行选择）',
          url: '/api/mes-product/qms-inspection-document/page?statusStr=2,3,5,6&documentType=CQC',
          isPage: true,
          index: true,
          indexLabel: '序号',
          selection: true,
          rowSelectionType: 'single',
          columnDefs: [
            {
              label: '检验单号',
              prop: 'documentNo',
              search: true
            },
            {
              label: '生产工单',
              prop: 'sourceNo'
            },
            {
              label: '客户名称',
              prop: 'partnerName'
            },
            {
              label: '物料编码',
              prop: 'partNo'
            },
            {
              label: '物料名称',
              prop: 'partName'
            },
            {
              label: '产品型号',
              prop: 'partModel'
            }
          ]
        };
      } else if (type == 'partnerName') {
        this.modalName = 'partnerCodeModal';
        this.$refs.commonModalTemplate.showModal();
        this.tableOption = {
          modalTitle: '选择客户信息（双击进行选择）',
          url: '/api/mes-admin/customer/page',
          isPage: true,
          rowSelectionType: 'single',
          menuWidth: 100,
          columnDefs: [
            {
              label: '客户编码',
              prop: 'code',
              search: true,
              rules: [
                {
                  required: true,
                  message: '请输入编码',
                  trigger: 'blur'
                }
              ]
            },
            {
              label: '客户名称',
              prop: 'name',
              search: true,
              rules: [
                {
                  required: true,
                  message: '请输入',
                  trigger: 'blur'
                }
              ]
            }
          ]
        };
      } else if (type == 'label') {
        this.modalName = 'labelTemplateModal';
        this.$refs.commonModalTemplate.showModal();
        this.tableOption = {
          modalTitle: '选择标签模版（双击进行选择）',
          url: `/api/mes-admin/labeltemplate/page?is_latest=true`,
          isPage: true,
          rowSelectionType: 'single',
          searchMenuSpan: 24,
          columnDefs: [
            {
              label: '大类',
              prop: 'type',
              type: 'select',
              dicUrl: '/api/blade-system/dict/dictionary?code=sysSerial',
              cascader: ['subType'],
              props: {
                label: 'dictValue',
                value: 'dictKey'
              },
              search: true
            },
            {
              label: '小类',
              prop: 'subType',
              dicUrl: '/api/blade-system/dict/dictionary?code={{key}}',
              props: {
                label: 'dictValue',
                value: 'dictKey'
              },
              type: 'select',
              search: true
            },
            {
              label: '模版名称',
              prop: 'fileName',
              search: true
            },
            {
              label: '模版代码',
              prop: 'code',
              search: true
            },
            {
              label: '客户/供应商',
              prop: 'clientName'
            },
            {
              label: '缩略图',
              prop: 'thumbnailUrl'
            },
            {
              label: '标签地址',
              prop: 'fileUrl'
            },
            {
              label: '打印列数',
              prop: 'columnCount'
            },
            {
              label: '打印份数',
              prop: 'copies'
            },
            {
              label: '备注',
              prop: 'remark'
            }
          ]
        };
      } else if (type == 'print') {
        this.modalName = 'printersModal';
        this.$refs.commonModalTemplate.showModal();
        this.tableOption = {
          modalTitle: '选择打印机（双击进行选择）',
          url: '/api/mes-product/ems-equipment/page?type=PRINTER',
          isPage: true,
          rowSelectionType: 'single',
          columnDefs: [
            {
              label: '打印机编码',
              prop: 'code',
              search: true,
              searchLabelWidth: 110
            },
            {
              label: '打印机名称',
              prop: 'name',
              search: true,
              searchLabelWidth: 110
            }
          ]
        };
      }
    },
    /**
     * 选择模态框行数据
     */
    getSelectedRows(rowData) {
      switch (this.modalName) {
        case 'partnerCodeModal':
          this.$set(this.query, 'partnerName', this._get(rowData, 'name', ''));
          break;
        case 'partNoModal':
          this.$set(this.query, 'partNo', this._get(rowData, 'partNo', ''));
          break;
        case 'failureModal':
          this.abnormalForm.failureId = rowData.id;
          this.abnormalForm.failureCode = rowData.code;
          this.abnormalForm.failureName = rowData.name;
          break;
        case 'sourceNoModal':
          this.$set(this.query, 'sourceNo', this._get(rowData, 'orderNo', ''));
          break;
        case 'documentNoModel':
          this.$set(this.query, 'documentNo', this._get(rowData, 'documentNo', ''));
          break;
        case 'workOrderModal':
          this.addForm.sourceId = rowData.id;
          this.addForm.sourceNo = rowData.orderNo;
          this.addForm.workOrderQuantity = rowData.planQuantity;
          this.addForm.partnerName = rowData.partnerName;
          this.addForm.partMasterId = rowData.partMasterId;
          this.addForm.partNo = rowData.partNo;
          this.addForm.partName = rowData.partName;
          this.addForm.partModel = rowData.partModel;
          this.getWorkOrderDetail(rowData.orderNo);
          break;
        case 'userModal':
          this.basicInfoForm.examineBy = rowData.id;
          this.basicInfoForm.examineByName = rowData.realName;
          break;
        case 'labelTemplateModal':
          this.$set(this.printDialog.form, 'labelTemplateId', this._get(rowData, 'id', ''));
          this.$set(this.printDialog.form, 'labelTemplateName', this._get(rowData, 'fileName', ''));
          break;
        case 'printersModal':
          this.$set(this.printDialog.form, 'printersId', this._get(rowData, 'id', ''));
          this.$set(this.printDialog.form, 'printersName', this._get(rowData, 'name', ''));
          break;
        default:
          break;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
::v-deep .firstInspectionRecordDialog {
  .el-dialog__body {
    padding-top: 10px;
    .titleIcon {
      display: flex;
      align-items: center;
      margin: 5px 0;
      &.flex {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0;
      }
      .name {
        font-weight: bold;
      }
    }
  }
}
</style>
